#include "DBQuery.h"
#include "TestBase.h"
#include "IDatabase.h"
#include "SQLiteDatabaseDriver.h"

TestBase::TestBase()
{
	info.Name = "SQLiteDatabaseDriver test 0";
	info.Category = 0x0200;
	info.CategoryName = "SQLiteDatabaseDriver";
	info.File = __FILE__;
}

bool TestBase::Run()
{
	SQLiteDatabaseDriver db;
	DatabaseConnectionInfo info;
	DBQuery query;
	IDBQueryResult* res;
	info.DB = "TestModules/SQLiteDatabaseDriverTest0.db";
	if (!db.Open(&info))
	{
		return false;
	}
	db.BatchExec("TestModules/SQLiteDatabaseDriverTest0.sql");
	query.SetFormatString("select * from test_table");
	res = db.Query(query);
	db.Close();
	unlink(info.DB.c_str());
	if (res != NULL)
	{
		delete res;
		return true;
	}
	else
	{
		return false;
	}
}